package com.qcu.controller.staff;

import com.qcu.annotation.LimitRate;
import com.qcu.annotation.RequireAuthorization;
import com.qcu.dto.Review;
import com.qcu.service.PostService;
import com.qcu.util.Response;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;


/**
 * @Name: MyComputer
 * @ClassName StaffPostController
 * @Description:
 * @date 2025/2/15 18:26
 */
@RestController
@RequestMapping("/staff/post")
public class StaffPostController {
    @Resource
    private PostService PostService;

    /**
     * 分页获取所有帖子
     */
    @GetMapping
    @LimitRate(key = "getStaffPost",permitsPerSecond = 2,expire = 10,msg = "八嘎雅鹿，你滴点那么快滴干什么滴干活...")
    public Response list(@RequestParam Integer page, @RequestParam Integer size) {
        return PostService.getAllPost(page,size);
    }

    /**
     * 审核帖子
     * @param review
     * @return
     */
    @PutMapping
    @RequireAuthorization({"PLAIN"})
    public Response audit(@RequestBody Review review){
        return PostService.auditPost(review);
    }
}
